package main;

import GUI.layout.layers.*;
import common.GameConstants;
import datastructure.board.Board;

import org.apache.log4j.BasicConfigurator;
import org.apache.log4j.Logger;

import javax.swing.*;

import java.awt.*;

/**
 * User: Lars Christian Ersly
 * Date: 03-06-11
 * Time: 14:54
 */
public class Main {

    // Define a static logger variable so that it references the
    // Logger instance named "Main".
    static Logger logger = Logger.getLogger(Main.class);

    public Main(){
        BasicConfigurator.configure();

        JFrame frame = new JFrame("Board");
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

        logger.debug("adding BoardLayout to frame");
        frame.setLayout(new FlowLayout(FlowLayout.LEFT));

        Board board = Board.createTestBoard();

        JLayeredPane layeredPane = new JLayeredPane();
        layeredPane.setPreferredSize(new Dimension(GameConstants.boardWidthTotal, GameConstants.boardHeightTotal));


        layeredPane.add(new ConveyorBeltLayer(board.getConveyorBeltElements()), 3);
        layeredPane.add(new WallLayer(board.getWallElements()), 4);
        layeredPane.add(new LaserLayer(board.getLaserElements()), 5);
        layeredPane.add(new HoleLayer(board.getHoleElements()), 2);
        layeredPane.add(new PlayerLayer(board.getPlayers()), 10);
        layeredPane.add(new GridLayer(), 1);


        frame.add(layeredPane);

        logger.info("The layeredPane contains " + layeredPane.getComponentCount() + " layers");

        frame.setContentPane(layeredPane);
        frame.setResizable(false);

        frame.pack();
        logger.info("Window size is: " + frame.getBounds().getWidth() + "x" + frame.getBounds().getHeight());
        frame.setVisible(true);
    }

    public static void main(String[] args){
        new Main();
    }
}
